﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace YakShaver.WCSF.BuildManager.BusinessEntities
{
    public class NantCommandLineOptions
    {
        private string _targetFramework = NantTargetFramework.NET35;
        private string _buildFile = "sandbox.build";
        private string _webUrl;
        private string _workingDirectory;
        private string _logFileName;

        public string LogFileName
        {
            get { return _logFileName; }
            set { _logFileName = value; }
        }

        public string WebUrl
        {
            get { return _webUrl; }
            set { _webUrl = value; }
        }

        public string WorkingDirectory
        {
            get { return _workingDirectory; }
            set { _workingDirectory = value; }
        }
        public string BuildFile
        {
            get { return _buildFile; }
            set { _buildFile = value; }
        }

        public string TargetFramework
        {
            get { return _targetFramework; }
            set { _targetFramework = value; }
        }

        private IDictionary<string, string> _additionalProperties = new Dictionary<string,string>();

        public IDictionary<string, string> AdditionalProperties
        {
            get { return _additionalProperties; }
            set { _additionalProperties = value; }
        }

        public override string ToString()
        {
            StringBuilder returnString = new StringBuilder();
            returnString.AppendFormat(" -t:{0}", TargetFramework);
            returnString.AppendFormat(" -buildfile:{0}", BuildFile);
            returnString.AppendFormat(" -D:yakShaver.webUrl={0}", WebUrl);
            returnString.AppendFormat(" -D:yakShaver.WorkingDirectory={0}", WorkingDirectory);
            returnString.AppendFormat(" -D:yakShaver.LogFile={0}", LogFileName);

            foreach (string key in AdditionalProperties.Keys)
            {
                returnString.AppendFormat(" -D:{0}={1}", key, AdditionalProperties[key]);
            }

            return returnString.ToString();
        }
    }

    public class NantTargetFramework
    {
        public const string NET35 = "net-3.5";
        public const string NET30 = "net-3.0";
        public const string NET20 = "net-2.0";
        public const string NET11 = "net-1.1";
        public const string NET10 = "net-1.0";
    }
}
